package com.fhminyi.GUI;

import com.fhminyi.model.User;

import javax.swing.*;
import java.awt.*;

public class AdminManagementFrame extends JFrame {
    private User user;
    private UserManagementPanel userManagementPanel;
    private OrderManagementPanel orderManagementPanel;
    private CommentManagementPanel commentManagementPanel;

    public AdminManagementFrame(User user) {
        this.user = user;
        setTitle("后台管理");
        setSize(800, 600);
        setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        setLocationRelativeTo(null);

        // 主面板
        JPanel mainPanel = new JPanel(new BorderLayout());
        mainPanel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); // 设置边距
        mainPanel.setBackground(new Color(245, 245, 245)); // 设置背景色

        // 用户管理面板
        userManagementPanel = new UserManagementPanel();

        // 订单管理面板
        orderManagementPanel = new OrderManagementPanel();

        // 评论管理面板
        commentManagementPanel = new CommentManagementPanel();

        // 选项卡面板
        JTabbedPane tabbedPane = new JTabbedPane();
        tabbedPane.addTab("用户管理", userManagementPanel);
        tabbedPane.addTab("订单管理", orderManagementPanel);
        tabbedPane.addTab("评论管理", commentManagementPanel);

        mainPanel.add(tabbedPane, BorderLayout.CENTER);

        add(mainPanel);

        // 加载数据
        userManagementPanel.loadUsers();
        orderManagementPanel.loadOrders();
        commentManagementPanel.loadComments();
    }
}
